<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<style type="text/css">
	label.col-2{width: 120px;}

	#tuan{
		background-color: #f2dede;
	    padding: 10px;
	    border-radius: 10px;
	}
	
	
	.guige{background-color:#f9f9f9; border-radius: 3px;}
	.guige tr{border:#ddd 1px solid; list-style: none; padding: 5px 10px; padding: 0px; position: relative;}
	.guige td{padding: 5px 10px;}
	.guige td.text{width: 100px; text-align: center; border-right: #ddd 1px solid;}
	.guige td.del{width: 25px; cursor: pointer;}
	.guige td.input{}
	.guige i{
	    font-size: 25px;
    	line-height: 20px;
	}

	.models{background-color:#f9f9f9; border-radius: 3px;}
	.models tr{border:#ddd 1px solid; list-style: none; padding: 5px 10px; padding: 0px; position: relative;}
	.models td{padding: 5px 10px;}
	.models td.text{min-width: 100px; text-align: center; border-right: #ddd 1px solid;}
	.models td.text label{background-color: #fff; width: 100%; display:inline-block;}
	.models td.model-del{text-align: center; padding: 0; cursor: pointer; width: 50px; padding: 0 5px;}
	.models td.input{}
	.models i{
		/*position: absolute;
	    right: -30px;*/
	    font-size: 25px;
    	line-height: 20px;
	    /*line-height: 25px;
	    cursor: pointer;*/
	}

	
</style>
<title>产品编辑</title>
</head>
<body>
<div class="pd-20">
	<form action="" method="post" class="form form-horizontal" id="form1">
		
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>产品名称：</label>
			<div class="formControls col-4">
				<input type="text" class="input-text" value="" placeholder="" id="goods_name" name="goods_name" nullmsg="产品名称不能为空！" datatype="s1-100">
			</div>
			<div class="col-2"> </div>
			
			
		</div>
		

		<div class="row cl">
			<label class="form-label col-2">广告单价：</label>
			<div class="formControls col-1">
				<input type="number" class="input-text" value="" placeholder="" id="goods_quan" name="goods_quan">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-2">广告位尺寸：</label>
			<div class="formControls col-3">
				<input type="text" class="input-text" value="" placeholder="" id="goods_size" name="goods_size">
			</div>
			<div class="col-2" style="line-height: 30px">
				例：80px*60px
			</div>
		</div>

		<!-- <div class="row cl">
			

			<label class="form-label col-2">生产日期：</label>
			<div class="formControls col-3">
				<input class="input-text datainp" id="goods_date" type="text" name="goods_date" value="" >
				
			</div>
			
		</div>

		 -->
		
	





		<div class="row cl">
			<label class="form-label col-2">参数：</label>
			<div class="formControls col-2"><input type="text" class="input-text" value="" placeholder="" id="goods_guige_title"></div>
			<div class="formControls col-4 guige">

					<input type="text" class="input-text" value="" placeholder="" id="goods_guige_value">
					<input type="hidden" name="goods_spec" id="goods_spec">

			</div>
			<div class="btn btn-secondary-outline radius col-2" id="guige-add">添加</div>
		</div>

		<div class="row cl">
			<label class="form-label col-2">示例：</label>
			<div class="formControls col-6">
				<table class="guige">
					<tr><td class="text">入口位置：</td><td class="input">首页幻灯片</td></tr>
				</table>
				
			</div>	
		</div>
		<div class="row cl">
			<label class="form-label col-2"></label>
			<div class="formControls col-6">
				<table class="guige" id="guige-list">
					<!-- <li><span class="text">颜色：</span><span class="input"><input type="text" name="" class="input-text"></span></li> -->
				</table>
				
			</div>	
		</div>



		<div class="row cl" style="margin-top: 1px;">
			<label class="form-label col-2"></label>
			<div class="formControls col-6">
				<table class="models" id="model-list">
					
					<!-- <tr><td class="text">'+model_1+'</td><td class="text">'+model_2+'</td><td class="text">'+model_3+'</td><td class="model-del"><i class="icon Hui-iconfont" data-id="1"></i><input type="hidden" name="goods_sku" value="'+inputvalue+'"></td></tr> -->
				</table>
				
			</div>	
		</div>	

		

		


		
		<div class="row cl">
			<label class="form-label col-2">上架</label>
			<div class="formControls col-3 s-msg">
			    <div class="radio-box">
			        <label class="lh-26">
			        	<input type="radio" name="goods_show" value="1" >显示
			        </label>
			    </div>
			    <div class="radio-box">
			        <label class="lh-26">
			        	<input type="radio" name="goods_show" value="0" checked>不显示
			        </label>
			     </div>
			</div>
			
		</div>	
		


		<div class="row cl">
			<label class="form-label col-2">产品图片：</label>
			<div class="formControls col-10" >
				
				<span class="l mb-10 fujian" id="fujian">
					
				</span>
				<i class="Hui-iconfont fujianadd" onclick="_open('添加附件','article-imageupload.html?type=image&idname=fujian&api=adgoods&single=0&inputname=goods_images2','750px','470px',true)">&#xe610;</i>


				<!-- <a id="btn-img" class="btn btn-secondary radius ml-10" onclick="_open('添加附件','article-imageupload.html?type=file&idname=fujian&api=goods&single=0&inputname=goods_images','750px','470px',true)">选择附 件</a>-->
	
				
	
			</div>
		</div>
		
		
		<div class="row cl">
			<label class="form-label col-2">文章内容：</label>
			<div class="formControls col-10"> 
				<script id="editor" name="goods_info" type="text/plain" ></script> 
			</div>
		</div>
		

		
</div>

<div class="row cl pr-20" style="position:fixed; bottom:10px; width: 200px; right: 10px; text-align: right; z-index:1000; ">
	
		<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
		<button onClick="removeIframe();" class="btn btn-default radius" type="button" style="margin-left:10px;">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
	
</div>
</form>

<script type="text/javascript" src="lib/layer/2.1/layer.js"></script> 

<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script> 
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.config.js"></script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="js/template-native.js"></script> 
<script type="text/javascript" src="js/s.js"></script> 

<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" /> 


<script type="text/javascript">




// 添加参数
var index=1;
$(document).on('click','div#guige-add',function(){

	var title=$("#goods_guige_title").val();
	var value=$("#goods_guige_value").val();
	var save=$("#goods_spec").val();
	if(title.replace(/\s/g, "").length==0 || value.replace(/\s/g, "").length==0){
		layer.msg("请填写参数内容", {icon:2,time:1000});
		return;
	}
	if(save.replace(/(^\s+)|(\s+$)/g, "").length>0){
		save=JSON.parse(save);

	}else{
		save=[];
	}
	save=save.concat([{index:index,title:title,value:value}]);	
	$("#guige-list").append('<tr><td class="text">'+title+'</td><td class="input">'+value+'</td><td class="del"><i class="icon Hui-iconfont" data-id='+index+'>&#xe60b;</i></td></tr>');
	save=JSON.stringify(save); 
	$("#goods_spec").val(save);
	index++;
	$("#goods_guige_title").val("");
	$("#goods_guige_value").val("");
})
// 删除参数
$(document).on('click','#guige-list td.del i',function(){
	var index=$(this).data("id");

	var string=$("#goods_spec").val();
	var list=JSON.parse(string);
	var that=$(this);
	for(k in list){
		if(list[k].index==index){
			that.parent().parent("tr").remove();
			list.splice(k,1);
			list=JSON.stringify(list); 
			$("#goods_spec").val(list);
		}
	}
})





function removeIframe(){
	var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}



function sortchange(){
	var strvalue=$("#sort").val();
	$("#selectsort").text("/"+strvalue);
}




$(function(){

	

	

	
	$(document).on('click','input[name=is_group]',function(){
		var value=$(this).val();
		if(value==1){
			$("#tuan").show();
		}else{
			$("#tuan").hide();

		}
	})



	



	

	// $('#goods_date').dateRangePicker(
	// {
	// 	autoClose: true,
	// 	singleDate : true,
	// 	showShortcuts: false,
	// 	singleMonth: true,


	// 	startOfWeek: 'monday',
	// 	format: 'YYYY-MM-DD HH:mm:ss',
	// 	time: {
	// 		enabled: true
	// 	},
	// 	defaultTime: moment().startOf('day').toDate(),
	// 	defaultEndTime: moment().endOf('day').toDate(),

	// });




	$("#form1").attr("action", API_PRODUCTAD); 

	var editid=getUrlParam('editid');//编辑菜单id




	if(editid!==null){	     
	    var eidturl=API_PRODUCTAD+"?id="+editid;
	    $("#form1").attr("action", eidturl); 
	    // 读取即将编辑的文章信息
	    $.getJSON(eidturl,function(data){

	    	if(!checkStatus(data)) return;//判断登录

	    	if(data.datas==''){
	    		layer.msg("数据加载错误", {icon:2,time:1000});
	    	}else{
	            $("#goods_name").val(data.datas.goods_name);
	            $("#goods_size").val(data.datas.goods_size);
	            $("#goods_quan").val(data.datas.goods_quan);


	           

	            
	            $("input[name='is_show'][value="+data.datas.is_show+"]").attr("checked",true);
	            

	            
                	

	            

	            
	            var list=data.datas.goods_spec;
	            $("#goods_spec").val(list);
	            if(list!==""){
	            	list=JSON.parse(list);
	            	for(j in list){
		            	$("#guige-list").append('<tr><td class="text">'+list[j].title+'</td><td class="input">'+list[j].value+'</td><td class="del"><i class="icon Hui-iconfont" data-id='+list[j].index+'>&#xe60b;</i></td></tr>');
		            }
	            }

	 

              
    
    			 

	            // 缩略图
	            var goods_images=data.datas.goods_images;
	        	for (x in goods_images){
	        		$('#fujian').show();
	        	   	$('#fujian').append('<li><img src="'+getIcon(goods_images[x])+'"><i class="Hui-iconfont" onclick="fj_close(this);">&#xe706;</i><input type="hidden" name="goods_images2['+x+']" value="'+goods_images[x]+'"></li>');	
	        	}
	        	

       

	            UE.getEditor('editor').addListener('ready', function (editor) {
		            UE.getEditor('editor').setContent(data.datas.goods_info);
	            });

	            


	            // $("input[name='goods_show'][value="+data.datas.goods_show+"]").attr("checked",true);

	            // $("#is_new").find("option[value='"+data.datas.is_new+"']").attr("selected",true);
	            

	 
	        }
	    })
	}


	Validformsubmit("#form1");

	
	
	
	
	// 富文本编辑器
	getueidt()

});


// 移除选中的图片
function fj_close(obj){
	$(obj).parents("li").remove();
}


</script>
</body>
</html>